from django.contrib import admin
from django.urls import path,include
from rest_framework.routers import DefaultRouter

from drfstudy.models import Classes
from drfstudy.serializers import StudentSerializer
from .views import StudentViewSet,ClassesViewSet
from rest_framework.routers import DefaultRouter

urlpatterns = [
    # # 127.0.0.1:8000/drfstudy/students  ==》get  ==>StudentViewSet==>list方法
    # path('students/',StudentViewSet.as_view({'get':'list','post':'create'})),
    #
    # path('students/<pk>/',StudentViewSet.as_view({'get':'retrieve','put':'update','delete':'destroy'})),

]

router = DefaultRouter()
#注册
router.register('students', StudentViewSet)
router.register('classes', ClassesViewSet)
#拼接
urlpatterns +=router.urls